package screen;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

import main.GameCanvas;
import model.Command;
import utilities.FrameImage;
import utilities.GameResource;
import font.BitmapFont;

//////////////////////
public class PaintPopup {
	public static FrameImage arrow,arrow2; 
	static PaintPopup instance;
	public static PaintPopup gI(){
		if(instance==null)
			instance=new PaintPopup();
		return instance;
	}
	
	public static int[] color=new int[]{0x305d79,0x519dcd,0x519dcd,0x72beed,0x72edd6,0xffffff};
	
	private int m_h,x,y,numTab;	
	public int focusTab , m_w, m_wTab, indexStart=0 , maxTab;
	private String name;
	
	
	public static void paintArrow(Graphics g,int index,int x, int y, int w, int deltaX){
		Image img = GameResource.instance.imgArrow;
		g.drawRegion(img, 0, 0, img.getWidth(), img.getHeight(), Sprite.TRANS_NONE, x - deltaX - 5, y, 20);
		g.drawRegion(img, 0, 0, img.getWidth(), img.getHeight(), Sprite.TRANS_ROT180, x + w + deltaX, y, 20);
	}
	
	public static void paintArrowVertical(Graphics g,int index,int x, int y, int w, int deltaY){
		Image img = GameResource.instance.imgArrow;
		g.drawRegion(img, 0, 0, img.getWidth(), img.getHeight(), Sprite.TRANS_ROT90, x, y - deltaY - 5, 20);
		g.drawRegion(img, 0, 0, img.getWidth(), img.getHeight(), Sprite.TRANS_ROT270, x, y + w + deltaY, 20);
	}
	
    public void setName(String name){
    	this.name=name;
    }
    
    public String getName(){
    	return name;
    }
	
	public static void paintSelect(Graphics g,int x,int y,int w,int h){		
		g.setColor(0xfbd634);
		g.fillRect(x, y, w, h);		
	}

	public static void drawCircle(Graphics g, int x, int y){
		g.drawImage(GameResource.instance.imgCirle, x, y, 0);
    }
    
	public void setInfo(String na,int wp,int hp,int num){		
		name=na;
		m_w=wp;
		m_h=hp;
		numTab=num;
		m_wTab=BitmapFont.m_bmFont.stringWidth(na)+10;
		
		if(m_wTab<40)
			m_wTab=40;
		x=GameCanvas.hw - m_w/2;
		y=GameCanvas.hh - m_h/2;
		focusTab=0;

		maxTab=(m_w - m_wTab)/10;	
		indexStart=0;			
	}	

	public void setNameAndFocus(String na,int focus){
		name=na;
		int aa=BitmapFont.m_bmFont.stringWidth(name)+10;
		
		if(aa > m_wTab){
			m_wTab=aa;
			maxTab=(m_w - m_wTab)/10;
		}		
		focusTab=focus;				
		if(focusTab>=maxTab&&maxTab>0){				
			indexStart=focusTab-(maxTab-1);
		}
		if(focusTab<indexStart)
			indexStart=focusTab;
	}
	
	public void setNumTab(int num){	
		
		//colorTab=new int[num];
		numTab=num;		
	}
	
	public void paint(Graphics g) {			
		paintBoxTab(g);		
	}	
	
	public void paintShopScr(Graphics g){
		g.translate(-g.getTranslateX(), -g.getTranslateY());			
		g.setClip(0, 0, GameCanvas.w, GameCanvas.h);
		
		int m_wTab = BitmapFont.m_bmFont.stringWidth(name) + 20;
		
		if(m_wTab < 100){
			m_wTab = 100;
		}
		
		//paint active tab
		paintRoundRect(g, x + m_w/2 - m_wTab/2, y, m_wTab, 17, 0xfb8d34);
		BitmapFont.drawBoldFont(g, name, x + m_w/2, y + 2, 0x3a001e, 2);
		
		//paint all tab
		if(numTab > 1){
			int heightTmp = 20;
			int total = heightTmp * numTab;
			int tmpY = y + m_h/2 - total/2;
			for(int i = 0; i < numTab; i++){
				int y = tmpY + i*heightTmp + i + 1;
				if(i == focusTab){
					paintRoundRect(g, x - 30, y, 50, heightTmp, 0xe7fb34);
				}
				else{
					paintRoundRect(g, x - 30, y, 50, heightTmp, 0xfb8d34);
				}
				BitmapFont.drawOutlinedString(g, "" + i, x - 15, y + 2, 0xffff00, 0x000000, 2);
			}
		}
		
		//paint background
		paintRoundRect(g, x, y + 15, m_w, m_h, 0xfb8d34);
	}
	
	public void paintBoxTab(Graphics g){		
		g.translate(-g.getTranslateX(), -g.getTranslateY());			
		g.setClip(0, 0, GameCanvas.w, GameCanvas.h);
		
		int m_wTab = BitmapFont.m_bmFont.stringWidth(name) + 20;
		
		if(m_wTab < 100){
			m_wTab = 100;
		}
		
		//paint active tab
		paintRoundRect(g, x + m_w/2 - m_wTab/2, y, m_wTab, 17, 0x3c8dc0);
		BitmapFont.drawBoldFont(g, name, x + m_w/2, y + 2, 0x3a001e, Graphics.HCENTER);
		
		//paint all tab
		if(numTab > 1){
			int heightTmp = 20;
			int total = heightTmp * numTab;
			int tmpY = y + m_h/2 - total/2;
			for(int i = 0; i < numTab; i++){
				int y = tmpY + i*heightTmp + i + 1;
				if(i == focusTab){
					paintRoundRect(g, x - 30, y, 50, heightTmp, 0xe7fb34);
				}
				else{
					paintRoundRect(g, x - 30, y, 50, heightTmp, 0xfb8d34);
				}
				BitmapFont.drawOutlinedString(g, "" + i, x - 15, y + 2, 0xffff00, 0x000000, Graphics.HCENTER);
			}
		}
		
		//paint background
		paintBox(g, x, y + 15, m_w, m_h - 12);
	}
	
	public static void paintBox(Graphics g,int x,int y,int w,int h){
		g.setColor(color[0]);
		g.fillRect(x, y, w, h);
		g.setColor(color[2]);
		g.fillRect(x + 1, y + 1 , w - 2, h - 2);
	}
	
	public static void paintBox(Graphics g, int x, int y, int w, int h, int lineHeight, int color1, int color2){
		g.setColor(color2);
		g.fillRect(x, y, w, h);
		g.setColor(color1);
		g.fillRect(x + lineHeight, y + lineHeight , w - lineHeight * 2, h - lineHeight * 2);
	}

	public void paintTabs(Graphics g){		
		g.translate(-g.getTranslateX(), -g.getTranslateY());			
		g.setClip(0, 0, GameCanvas.w, GameCanvas.h);
		paintRoundRect(g, x, y, m_w, m_h, color[0]);
		int tmpW = 0;
		if(m_wTab > 45){
			tmpW = m_wTab - 45;
			m_wTab = 40;
		}
		
		int ii=0;		
		for (int i = indexStart; i < focusTab; i++) {
			ii=i;//-indexStart;
			PaintPopup.paintRoundRect(g, x + 3 + ii * 10, y + 3, 30+tmpW, 20, 15, 0x77eedd);
			PaintPopup.paintRoundRect(g, x + 3 + ii * 10+1, y + 3+1, 30+tmpW, 20, 15, 0x72beed);
		}
		int aa=numTab;
		if(aa>=maxTab)
			aa=maxTab+indexStart;			
		for (int i = aa - 1; i >= focusTab; i--) {	
			ii=i-indexStart;
			int tmp = x + 3 + m_wTab - 8 + ii * 10-7;
			if(i != focusTab){
				PaintPopup.paintRoundRect(g, tmp-20, y + 3,  41+tmpW, 20, 15, 0x77eedd);
				PaintPopup.paintRoundRect(g, tmp-20, y + 4, 40+tmpW, 19, 15, 0x72beed);
			}
			if(i == focusTab){
				tmp = x + 3 + ii * 10;
				PaintPopup.paintRoundRect(g, tmp, y + 3, 46+tmpW, 20, 15, 0x77eedd);
				PaintPopup.paintRoundRect(g, tmp+1, y + 3+1, 44+tmpW, 20, 15, 0x569cc8);
			}
		}	
		
		paintRoundRect(g, x + 3, y + 18, m_w -6, m_h - 21,color[2]);	
		paintRoundRect(g, x + 3, y + 18, 20, 20, 0,color[2]);	
		
		BitmapFont.drawBoldFont(g, name, x+3 + m_wTab/2+(focusTab-indexStart)*10, y+3+10-7, 0x3a001e, Graphics.HCENTER);
	}		
	
	public static void paintRoundRect(Graphics g, int x, int y, int w, int h,
			int color1) {
		g.setColor(color1);
		g.fillRoundRect(x, y, w, h, 20, 20);
	}
	
	public static void paintRoundRect(Graphics g, int x, int y, int w, int h, int r,
			int color1) {
		g.setColor(color1);
		g.fillRoundRect(x, y, w, h, r, r);
	}
	
	public static void paintCell(Graphics g,int x,int y,int w){
		g.setColor(0x3c8dc0);		
		g.fillRect(x, y, w, w);
		g.setColor(color[2]);
		g.drawRect(x, y, w, w);
	}
	
	public static void paintTopBar(Graphics g) {
		g.setColor(0x3c8dc0);
		g.fillRect(0, 0, GameCanvas.w, GameCanvas.hBottomBar);
		
		g.setColor(0x72beed);
		g.drawLine(0, GameCanvas.hBottomBar, GameCanvas.w, GameCanvas.hBottomBar);
		
		g.setColor(0x3a7092);
		g.drawLine(0, GameCanvas.hBottomBar + 1, GameCanvas.w, GameCanvas.hBottomBar + 1);
	}
	
	public static void paintBottomBar(Graphics g){
		int y = GameCanvas.h - GameCanvas.hBottomBar;
		g.setColor(0x3c8dc0);
		g.fillRect(0, y, GameCanvas.w, GameCanvas.hBottomBar);
		
		g.setColor(0x72beed);
		g.drawLine(0, y + 1, GameCanvas.w, y + 1);
		
		g.setColor(0x3a7092);
		g.drawLine(0, y, GameCanvas.w, y);
	}
	
	public static void paintCmdBar(Graphics g, Command left, Command center, Command right) {
		g.setColor(0x3c8dc0);
		int y = GameCanvas.h - GameCanvas.hBottomBar;
		g.fillRect(0, y, GameCanvas.w, GameCanvas.hBottomBar);

		g.setColor(0x72beed);
		g.drawLine(0, y + 1, GameCanvas.w, y + 1);
		
		g.setColor(0x3a7092);
		g.drawLine(0, y, GameCanvas.w, y);
		
		y += (BitmapFont.m_bmFont.getHeight()>>1) - 2;
		if (left != null) {
			BitmapFont.drawBoldFont(g, left.caption, 5, y, 0xffffff, Graphics.LEFT);
		}
		if (center != null) {
			BitmapFont.drawBoldFont(g, center.caption, GameCanvas.hw, y, 0xffffff, Graphics.HCENTER);
		}		
		if (right != null) {
			BitmapFont.drawBoldFont(g, right.caption, GameCanvas.w - 5, y, 0xffffff, Graphics.RIGHT);
		}
	}

	public static void paintLogo(Graphics g, int x, int y) {
		g.drawImage(GameResource.instance.imgLogo, x, y, Graphics.HCENTER|Graphics.VCENTER);
	}
	public static void paintKitty(Graphics g, int x, int y){
		g.drawImage(GameResource.instance.imgKitty, x, y, Graphics.RIGHT|Graphics.TOP);
	}
	public static void paintInputTf(Graphics g, boolean is, int x, int y, int w, int h) {
		if (is) {//focus input
			g.setColor(0x305d79);
			g.fillRect(x + 1, y + 1, w - 1, h - 1);
			g.setColor(0x72edd6);
			g.drawRect(x + 1, y + 1, w - 2, h - 2);

			//BitmapFont.drawBoldFont(g, "ABC", x + w, y + h / 2, 0xffffff, Graphics.LEFT | Graphics.VCENTER);
		}
		else
		{   g.setColor(0x3a7092);
			g.fillRect(x + 1, y + 1, w - 1, h - 1);
			g.setColor(0x519dcd);
			g.drawRect(x + 1, y + 1, w - 2, h - 2);
		}
	}

	public static void paintScroll(Graphics g, int x, int y, int h) {
		g.setColor(0x3ab648);
		g.fillRect(x, y, 4, h);
	}

	public static void paintBoxTab(Graphics g, String title, int x,
			int y, int w, int h, int color1, int color2) {
		if(title != null){
			paintRoundRect(g, x, y, w, h, 20, color2);
			
			int tabW = 4 + BitmapFont.m_facedeFont.stringWidth(title);
			paintRoundRect(g, x + 5, y + 5, 10 + BitmapFont.m_facedeFont.stringWidth(title), 40, color1);
			
			paintRoundRect(g, x + 5, y + 25, w - 10, h - 30, color1);
					
			BitmapFont.drawBoldFont(g, title, x + 5 + (tabW >> 1), y + 15, 0x3a001e, Graphics.HCENTER | Graphics.VCENTER);
		}
		else{
			paintRoundRect(g, x, y, w, h, 20, color2);
			paintRoundRect(g, x + 5, y + 5, w - 10, h - 10, color1);
		}
	}
	public static void paintCenerBoxTab(Graphics g, String title, int x, int y, int w, int h, int color1, int color2){
		int tmpW = BitmapFont.m_facedeFont.stringWidth(title);
		paintRoundRect(g, ((2*x+w-tmpW)>>1) - 5, y, tmpW+10 , 40, 15, color2);
		paintRoundRect(g, x, y+20, w, h, 20, color2);
		BitmapFont.drawBoldFont(g, title, (2*x+w-tmpW)>>1, y + 6, color1, Graphics.LEFT | Graphics.TOP);
	}
	
	public static void paintHealtyBar(Graphics g, int x, int y, int maxHelthy, int minHelthy, int bonousHealth){
		g.setColor(0xfa0909);		
		int check = minHelthy;
		for(int i=0; i < maxHelthy+bonousHealth; i++){
			if(i<check){
				if(bonousHealth > 0 && i >= maxHelthy)
					g.setColor(0xfd620e);
				else
					g.setColor(0xfa0909);
			}
			else{
				g.setColor(0x000000);
			}
			g.fillRect(x, y, 2, 6);
			x += 4;
		}
	}
	public static void paintMoney(Graphics g, int x, int y, int[] money){
		g.setColor(0xff0000);
		GameResource.instance.m_frameMoney.drawFrame(0, x, y+2, 0, g);
		BitmapFont.drawMoney(g, Integer.toString(money[1]), x + 12, y+4, Graphics.TOP|Graphics.LEFT);
		
		g.setColor(0xffff00);
		GameResource.instance.m_frameMoney.drawFrame(1, x+55, y+2, 0, g);
		BitmapFont.drawMoney(g, Integer.toString(money[0]), x + 67, y+4, Graphics.TOP|Graphics.LEFT);
	}
	public static void paintMoney(Graphics g, int x, int y, int money){
		g.setColor(0xff0000);
		g.drawRect(x, y, 10, 10);
		BitmapFont.drawNormalFont(g, Integer.toString(money), x + 12, y+4, 0xffffff, Graphics.TOP|Graphics.LEFT);
	}
	public static void paintInputScrBG(Graphics g, int x, int y, int w, int h, String title, String subTitle) {
		g.setClip(x, y, w, h);
		g.setColor(0x519dcd);
		g.fillRect(x, y, w - 1, h - 1);
		g.setColor(0x305d79);
		g.drawRect(x, y, w - 1, h - 1);
		g.setColor(0x9be5ff);
		g.fillRect(x + 1, y + 25, w - 2, Screen.ITEM_HEIGHT);
		BitmapFont.drawBoldFont(g, title, x + 10, y + 3, 0xffffff, Graphics.LEFT);
		BitmapFont.drawNormalFont(g, subTitle, x + 10, y + 28, 0x3a001e, Graphics.LEFT);
	}
	public static void paintBoxClock(Graphics g, int x, int y, String str){
		int tmp = 20;
		if(BitmapFont.m_bmFont.stringWidth(str)>(tmp-5))
			tmp = BitmapFont.m_bmFont.stringWidth(str) + 5;
		g.setColor(0x3c8dc0);
    	g.drawRect(x, y, tmp, 17);
    	g.setColor(0x9be5ff);
    	g.fillRect(x+1, y+1, tmp-1, 16);
    	BitmapFont.drawBoldFont(g, str, x+3, y+3, 0x000000, Graphics.LEFT|Graphics.TOP);
    }
	public static void paintLevel(Graphics g , int x, int y, String str, int colorLevel){
		g.setColor(0x000000);
		g.drawLine(x+5, y, x, y+5);
		g.drawLine(x+5, y, x+10, y+5);
		g.drawLine(x, y+6, x+3, y+6);
		g.drawLine(x+10, y+6, x+7, y+6);
		
		g.drawLine(x+3, y+7, x+3, y+10);
		g.drawLine(x+7, y+7, x+7, y+10);
		g.drawLine(x+3, y+10, x+7, y+10);
		
		g.setColor(0xf2262d);
		g.drawLine(x+5, y+1, x+5, y+1);
		g.drawLine(x+4, y+2, x+6, y+2);
		g.drawLine(x+3, y+3, x+7, y+3);
		g.drawLine(x+2, y+4, x+8, y+4);
		g.drawLine(x+1, y+5, x+9, y+5);
		
		g.fillRect(x+4, y+6, 3, 4);
		
		BitmapFont.drawMoney(g, str, x+15, y+4, Graphics.LEFT|Graphics.TOP);
	}
	
	static public void paintBarBlood(Graphics g,int x, int y, int width, int max, int min, int color1, int color2){
		int height = 3;
		g.setColor(color1);
		g.fillRect(x, y, width, height);
		width *= (float)min/(float)max;
		g.setColor(color2);
		g.fillRect(x, y, width, height);
	}
	
	static public void paintDice(Graphics g, int number, int x, int y, int achor, boolean status){
		achor %=4;//4 trang thái bay của xi ngau
		switch (achor) {
		case 1:
			y -= 1;
			break;
		case 2:
			y -= 2;
			break;
		case 3:
			y -= 1;
			break;
		default:
			break;
		}
		paintWings(g, x, y, achor);
		paintNumber(g, x, y, number, 0xffffff);
		if(achor == 2 || achor == 3)
			y +=1;
		paintFace(g, x-13, y-50, status);// mo mat nham mat cua xi ngau
	}
	
	static private void paintFace(Graphics g, int x, int y, boolean status){
		g.drawRegion(GameResource.instance.imgDice, 27, 0, 26, 27, Sprite.TRANS_NONE, x, y, 0);
		//draw eyes
		if(status){
			g.drawRegion(GameResource.instance.imgDice, 23, 46, 4, 7, Sprite.TRANS_NONE, x+18, y+8, 0);
			g.drawRegion(GameResource.instance.imgDice, 23, 46, 4, 7, Sprite.TRANS_NONE, x+5, y+8, 0);
			g.drawRegion(GameResource.instance.imgDice, 16, 53, 11, 5, Sprite.TRANS_NONE, x+8, y+15, 0);
		}
	}
	
	static private void paintNumber(Graphics g, int x, int y, int number, int color){
		switch (number) {
		case 1:
			paintRoundRect(g, x-3, y-13, 5, 4, 4, color);
			break;
		case 3:
			paintRoundRect(g, x-3, y-13, 5, 4, 4, color);
		case 2:
			paintRoundRect(g, x-10, y-19, 5, 4, 4, color);
			paintRoundRect(g, x+4, y-7, 5, 4, 4, color);
			break;
		case 5:
			paintRoundRect(g, x-3, y-13, 5, 4, 4, color);
		case 4:
			paintRoundRect(g, x-10, y-19, 5, 4, 4, color);
			paintRoundRect(g, x+4, y-7, 5, 4, 4, color);
			
			paintRoundRect(g, x-10, y-7, 5, 4, 4, color);
			paintRoundRect(g, x+4, y-19, 5, 4, 4, color);
			break;
		case 6:
			paintRoundRect(g, x-10, y-19, 5, 4, 4, color);
			paintRoundRect(g, x+4, y-7, 5, 4, 4, color);
			
			paintRoundRect(g, x-10, y-7, 5, 4, 4, color);
			paintRoundRect(g, x+4, y-19, 5, 4, 4, color);
			
			paintRoundRect(g, x-10, y-13, 5, 4, 4, color);
			paintRoundRect(g, x+4, y-13, 5, 4, 4, color);
			break;
		default:
			break;
		}
	}
	
	static private void paintWings(Graphics g, int x, int y, int achor){
		g.drawRegion(GameResource.instance.imgDice, 27, 27, 28, 33, Sprite.TRANS_NONE, x-14, y-33, 0);
		//paint wings 14 middle
		if(achor == 0){
			g.drawRegion(GameResource.instance.imgDice, 0, 0, 26, 25, Sprite.TRANS_NONE, x-40, y-40, 0);
			g.drawRegion(GameResource.instance.imgDice, 0, 0, 26, 25, Sprite.TRANS_MIRROR, x+14, y-40, 0);
		}//
		if(achor == 1){
			g.drawRegion(GameResource.instance.imgDice, 0, 25, 27, 21, Sprite.TRANS_NONE, x-41, y-38, 0);
			g.drawRegion(GameResource.instance.imgDice, 0, 25, 27, 21, Sprite.TRANS_MIRROR, x+14, y-38, 0);
		}
		if(achor == 2){
			g.drawRegion(GameResource.instance.imgDice, 0, 25, 27, 21, Sprite.TRANS_MIRROR_ROT180, x-41, y-27, 0);
			g.drawRegion(GameResource.instance.imgDice, 0, 25, 27, 21, Sprite.TRANS_ROT180, x+14, y-27, 0);
		}
		if(achor == 3){
			g.drawRegion(GameResource.instance.imgDice, 0, 0, 26, 25, Sprite.TRANS_MIRROR_ROT180, x-40, y-30, 0);
			g.drawRegion(GameResource.instance.imgDice, 0, 0, 26, 25, Sprite.TRANS_ROT180, x+14, y-30, 0);
		}
	}
	
	public static void paintCellBauCua(Graphics g, int x, int y, int w, int h, int boundColor, int bgColor){
		//fill background
		g.setColor(bgColor);
		g.fillRect(x, y, w, h);
		
		//fill bound
		g.setColor(boundColor);
		g.fillRect(x, y, w, 2);
		g.fillRect(x, y + h - 2, w, 2);
		g.fillRect(x, y, 2, h);
		g.fillRect(x + w - 2, y, 2, h);
		
		//draw center rect
		g.drawRect(x + 4, y + 4, w - 9, h - 9);
	}
	
	public static void paintMoneyBauCua(Graphics g, int pos, int x, int y){
		
		int boundColor = 0x4d4d4d;
		int bgColor = 0x9c9ea0;
		if(pos == 1){
			boundColor = 0xcb0230;
			bgColor = 0xff8700;
		}else if(pos == 2){
			boundColor = 0xcb3102;
			bgColor = 0xffff00;
		}
		
		g.setColor(0xffffff);
		g.fillRoundRect(x, y, 17, 17, 100, 100);
		
		g.setColor(bgColor);
		g.fillRoundRect(x + 1, y + 1, 14, 14, 100, 100);
		
		g.setColor(boundColor);
		g.drawRoundRect(x + 1, y + 1, 14, 14, 100, 100);
		
		g.drawRect(x + 5, y + 5, 6, 6);
		
		g.setColor(0xffffff);
		g.fillRect(x + 6, y + 6, 4, 4);
	}
	
	public static void paintDiceBauCua(Graphics g, int x, int y, int face){
		g.setColor(0xffffff);
		g.fillRect(x-7, y-7, 14, 14);
		g.setColor(0x6b93cf);
		g.drawRect(x-7, y-7, 14, 14);
		if(face == 0){
			g.drawRegion(GameResource.instance.imgDice, 52, 11, 11, 11, Sprite.TRANS_NONE, x, y, Graphics.HCENTER|Graphics.VCENTER);
		}else if(face == 1){
			g.drawRegion(GameResource.instance.imgDice, 55, 22, 8, 11, Sprite.TRANS_NONE, x, y, Graphics.HCENTER|Graphics.VCENTER);
		}else if(face == 2){
			g.drawRegion(GameResource.instance.imgDice, 55, 45, 12, 12, Sprite.TRANS_NONE, x, y, Graphics.HCENTER|Graphics.VCENTER);
		}else if(face == 3){
			g.drawRegion(GameResource.instance.imgDice, 4, 46, 13, 7, Sprite.TRANS_NONE, x, y, Graphics.HCENTER|Graphics.VCENTER);
		}else if(face == 4){
			g.drawRegion(GameResource.instance.imgDice, 53, 0, 12, 11, Sprite.TRANS_NONE, x, y, Graphics.HCENTER|Graphics.VCENTER);
		}else if(face == 5){
			g.drawRegion(GameResource.instance.imgDice, 55, 33, 12, 12, Sprite.TRANS_NONE, x, y, Graphics.HCENTER|Graphics.VCENTER);
		}	
		
	}
	
	public static void paintToBauCua(Graphics g, int x, int y, int w, int h, int arcW, int arcH){
		//fill background
		g.setColor(0xcfe0fa);
		g.fillRoundRect(x, y, w, h, arcW, arcH);
	
		//draw bound
		g.setColor(0x6b93cf);
		g.drawRoundRect(x, y, w, h, arcW, arcH);
		
		//fill white background
		g.setColor(0xffffff);
		g.fillRoundRect(x + 6, y + 6, w - 12, h - 12, arcW, arcH);
			
		g.setColor(0xcfe0fa);
		g.fillRoundRect(x + 16, y + 16, w - 32, h - 32, arcW, arcH);
	
		g.setColor(0xffffff);
		g.fillRoundRect(x + 20, y + 20, w - 40, h - 40, arcW, arcH);
		
		g.setColor(0x6b93cf);
		g.drawRoundRect(x + 20, y + 20, w - 40, h - 40, arcW, arcH);
		g.drawRoundRect(x + 22, y + 22, w - 44, h - 44, arcW, arcH);
		
		g.setColor(0xcfe0fa);
		g.fillRoundRect(x + 23, y + 23, w - 46, h - 46, arcW, arcH);
	}
	
	public static void paintTeacher(Graphics g, int x, int y, int status, int anchor){
		int wH = 0, wB = 0;
		if(anchor == Sprite.TRANS_MIRROR){
			wH = 5;
			wB = 9;
		}
		g.drawImage(GameResource.instance.m_arrShadow[1], x-7, y-6, Graphics.LEFT|Graphics.TOP);
		switch (status) {
		case 0://chum chan
			g.drawRegion(GameResource.instance.imgTeacher, 31, 0, 27, 25, anchor, x-10+wH, y-34, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 0, 12, 31, 11, anchor, x-14+wB, y-15, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 58, 11, 12, 5, anchor, x, y-5, Graphics.LEFT|Graphics.TOP);
			
			break;
		case 1:// dung len
			g.drawRegion(GameResource.instance.imgTeacher, 31, 0, 27, 25, anchor, x-10+wH, y-35, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 0, 12, 31, 11, anchor, x-14+wB, y-16, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 58, 5, 12, 6, anchor, x, y-6, Graphics.LEFT|Graphics.TOP);
			break;
		case 2:// gian chan
			g.drawRegion(GameResource.instance.imgTeacher, 31, 0, 27, 25, anchor, x-10+wH, y-34, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 0, 12, 31, 11, anchor, x-14+wB, y-15, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 58, 0, 12, 5, anchor, x, y-5, Graphics.LEFT|Graphics.TOP);
			break;
		case 3:// dung len
			g.drawRegion(GameResource.instance.imgTeacher, 31, 0, 27, 25, anchor, x-10+wH, y-35, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 0, 12, 31, 11, anchor, x-14+wB, y-16, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 58, 5, 12, 6, anchor, x, y-6, Graphics.LEFT|Graphics.TOP);
			break;
		// doc sach
		case 4:
			g.drawRegion(GameResource.instance.imgTeacher, 31, 0, 27, 25, anchor, x-10+wH, y-35, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 0, 0, 31, 12, anchor, x-14+wB, y-17, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 58, 0, 12, 5, anchor, x, y-5, Graphics.LEFT|Graphics.TOP);
			break;
		case 5:
			g.drawRegion(GameResource.instance.imgTeacher, 31, 0, 27, 25, anchor, x-10+wH, y-35, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 61, 16, 7, 3, anchor, x-2+wB, y-14, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 0, 0, 31, 12, anchor, x-14+wB, y-17, Graphics.LEFT|Graphics.TOP);
			g.drawRegion(GameResource.instance.imgTeacher, 58, 0, 12, 5, anchor, x, y-5, Graphics.LEFT|Graphics.TOP);
			break;		
		default:
			break;
		}
		
	}
	
	public static void drawBanQuaySo(Graphics g, int x, int y, int rotate){
		int w = GameCanvas.w2d3;
		g.setColor(0x0d7cb1);
		//g.fillArc(x-2, y-2, w+4, w+4, 0, 360);
		g.fillRoundRect(x-2, y-2, w+5, w+5, 500, 500);
		int color;
		int i;
		
		for(i = 0; i <8; i++){
			
    		color = (i%2==0)? 0x73fff4 : 0x1db2fa;
	    	g.setColor(color);
	    	g.fillArc(x, y, w, w, 45*i+rotate, 45);
		}
		
		for(i = 0; i <8; i++){
	    	color = (i%2==0)? 0x48c9d9 : 0x149adc;
	    	g.setColor(color);
	    	g.fillArc(x + w/6, y + w/6, w*2/3, w*2/3, 45*i+rotate, 45);
		}
		
		for(i = 0; i <8; i++){
	    	color = (i%2==0)? 0x73fff4 : 0x1db2fa;
	    	g.setColor(color);
	    	g.fillArc(x + w/6 + 4, y + w/6 + 4, w*2/3 - 8, w*2/3 - 8, 45*i+rotate, 45);
		}
		g.setColor(0xff0000);
		for(i = 0 ; i < 10; i ++){
			g.fillArc(x + w/6 + 6 + i, y + w/6 + 6 + i, w*2/3 - 12 - i*2, w*2/3 - 12 - i*2, 90-(i), i*2+1);
		}
		
		g.setColor(0x0878b0);
		g.fillRoundRect(x+w/2-9, y+w/2-9, 18, 18, 100, 100);
		g.setColor(0x80db41);
		g.fillRoundRect(x+w/2-7, y+w/2-7, 14, 14, 12, 12);
		
	}
	
	public static void drawCheckbox(Graphics g, int x, int y, int w, int h, int focus, boolean isCheck){
		if (focus == 2) {//focus input
			g.setColor(0x305d79);
			g.fillRect(x + 1, y + 1, w - 1, h - 1);
			g.setColor(0x72edd6);
			g.drawRect(x + 1, y + 1, w - 2, h - 2);			
		}
		else
		{
			g.setColor(0x3a7092);
			g.fillRect(x + 1, y + 1, w - 1, h - 1);
			g.setColor(0x72beed);
			g.drawRect(x + 1, y + 1, w - 2, h - 2);
		}
		if (isCheck) {               
    		g.drawRegion(GameResource.instance.imgCheckPass, 0, 24, 12, 12, Sprite.TRANS_NONE, x, y, 20);
        }
    }
}
